//
//  SNShopActivitiesListModel.m
//  app
//
//  Created by 王少宁 on 15/8/20.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "SNShopActivitiesListModel.h"

@implementation SNShopActivitiesListModel

- (instancetype)initWithArray:(NSArray *)array
{
    if ([super initWithArray:array]) {
        
        if (array && array.count) {
            
            _linage = array.count % 3 == 0 ? array.count/3 : array.count/3+1;
            self.cellHeight = SCREEN_WIDTH / 720 * 148;
            self.headerView = YES;
            self.headerTitle = @"推荐商家";
            self.rowNumber = _linage;
            
            NSMutableArray * mutableArray = [NSMutableArray array];
            
            for (int i = 0; i < array.count; i++) {
                
                if (i % 3 == 0) {
                    NSMutableArray * subArray = [NSMutableArray array];
                    [mutableArray addObject:subArray];
                }
                
                NSMutableArray * subArry = mutableArray[i/3];
                
                NSDictionary * dic = array[i];
                SNShopActivitiesListSubModel * model = [SNShopActivitiesListSubModel modelWithDict:dic];
                [subArry addObject:model];
            }
            
            _activitiesListArray = mutableArray;
        }
    }
    return self;
}

@end






@implementation SNShopActivitiesListSubModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if ([super init]) {
        _act_id = [dict[@"act_id"] stringValue];
        _name = dict[@"name"];
        _pic = dict[@"pic"];
        _width = [dict[@"width"] stringValue];
        _height = [dict[@"height"] stringValue];
        _intro = dict[@"intro"];
    }
    return self;
}


+ (instancetype)modelWithDict:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

@end